//
//  IWNewfeatureViewController.m
//  ItcastWeibo
//
//  Created by apple on 14-5-6.
//  Copyright (c) 2014年 itcast. All rights reserved.
//

#import "IWNewfeatureViewController.h"
#import "MSTaBbarController.h"
#import "MSAccuntLoginController.h"
#define IWNewfeatureImageCount 4

@interface IWNewfeatureViewController () <UIScrollViewDelegate>
{
    UIScrollView * scrollVc;
    UIImageView * imageView ;
    
    UIView * ViewView ;
    UIButton * btn;
}

@property (nonatomic, weak) UIPageControl *pageControl;
@end

@implementation IWNewfeatureViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    
     scrollVc = [[UIScrollView alloc]initWithFrame:self.view.frame];
    
    btn = [[UIButton alloc]initWithFrame:CGRectMake(ScreenWidth / 4,ScreenHeight-220 * px , ScreenWidth / 2, 150 * px)];
    [btn setTitle:@"开始体验" forState:UIControlStateNormal];
    btn.layer.borderWidth = 1;
    btn.layer.cornerRadius = 15 * px;
    btn.layer.borderColor = [UIColor whiteColor].CGColor;
    btn.titleLabel.font = [UIFont systemFontOfSize:Fontf];
    [btn addTarget:self action:@selector(goClass) forControlEvents:UIControlEventTouchUpInside];
    btn.backgroundColor = [UIColor clearColor];
//    btn.layer.cornerRadius = 10;
    btn.hidden = YES;
    
    
    for (int i=0; i<IWNewfeatureImageCount; i++)
    {
        
        ViewView = [[UIView alloc] initWithFrame:CGRectMake(ScreenWidth*i, 0, ScreenWidth, ScreenHeight)];
        
        
        NSString * imageStr = [NSString stringWithFormat:@"start%d",i+1];
        imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:imageStr]];
        imageView.frame = CGRectMake((ScreenWidth / 2) - 323 * px, (ScreenHeight / 2) - 387 * px, 646 * px, 774 * px);
        imageView.contentMode=UIViewContentModeScaleAspectFill;
        imageView.clipsToBounds=YES;
        [ViewView addSubview:imageView];
        
        [scrollVc addSubview:ViewView];
        
        [ViewView  addSubview:btn];
        
    }
    scrollVc.pagingEnabled = YES;
    
    
    scrollVc.showsHorizontalScrollIndicator=NO;

    scrollVc.contentSize = CGSizeMake(ScreenWidth*IWNewfeatureImageCount, CGRectGetHeight(ViewView.frame));
    scrollVc.contentOffset = CGPointMake(0, 0);
    scrollVc.delegate = self;
    
    
    
    [self.view addSubview:scrollVc];
    
    
}
-(void)goClass
{
    MSAccuntLoginController * VC =  [[MSAccuntLoginController alloc] init];
    [self presentViewController:VC animated:YES completion:nil];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//    NSLog(@"%g",scrollVc.contentOffset.x);
    if (scrollVc.contentOffset.x >= ScreenWidth * 3 )

    {
         btn.hidden = NO;
    }
    else
    {
        btn.hidden = YES;
    }

}
//导航栏（是否）隐藏:（是）
-(BOOL)prefersStatusBarHidden
{
    return YES;
}
@end
